<?php
/**
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 */

//$workshifts = $records[0];
$list = $records['list'];
//$year = $records['year'];
//$month = $records['month'];
//$employee_id = $records['employee_id'];
$rights = $records['rights'];
$pageNO = isset($_POST['pageNO'])?$_POST['pageNO']:'1';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
require_once ROOT_PATH . '/lib/confs/sysConf.php';
require_once ROOT_PATH . '/lib/controllers/ArgClassController.php';
require_once ROOT_PATH . '/lib/models/eimadmin/CompStruct.php';

$sysConst = new sysConf();
$locRights = $_SESSION['localRights'];

//$headingInfo =$this->popArr['headinginfo'];

//$currentPage = $this->popArr['currentPage'];
//$emplist = $this->popArr['emplist'];

/*if (!isset($this->getArr['sortField']) || ($this->getArr['sortField'] == '')) {
$this->getArr['sortField']=4;
$this->getArr['sortOrder4']='ASC';
}*/

function getNextSortOrder($curSortOrder) {
	switch ($curSortOrder) {
		case 'null' :
			return 'ASC';
			break;
		case 'ASC' :
			return 'DESC';
			break;
		case 'DESC'	:
			return 'ASC';
			break;
	}

}

$GLOBALS['lang_Common_SortAscending'] = $lang_Common_SortAscending;
$GLOBALS['lang_Common_SortDescending'] = $lang_Common_SortDescending;

function nextSortOrderInWords($sortOrder) {
	return $sortOrder == 'ASC' ? $GLOBALS['lang_Common_SortDescending'] : $GLOBALS['lang_Common_SortAscending'];
}
?>
<head>
<link href="../../themes/<?php echo $styleSheet; ?>/css/style.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 6]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE6_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<!--[if IE]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<script type="text/javascript" src="../../themes/<?php echo $styleSheet;?>/scripts/style.js"></script>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="../../scripts/octopus.js"></script>
<script type="text/javascript" src="../../scripts/ajax.js"></script>
<script type="text/javascript">
//<![CDATA[
function nextPage() {
	i=document.standardView.pageNO.value;
	i++;
	document.standardView.pageNO.value=i;
	document.standardView.submit();
}

function prevPage() {
	var i=document.standardView.pageNO.value;
	i--;
	document.standardView.pageNO.value=i;
	document.standardView.submit();
}

function chgPage(pNO) {
	document.standardView.pageNO.value=pNO;
	document.standardView.submit();
}

function sortAndSearch(sortField, sortOrder) {
	var uri = "<?php echo $_SERVER['PHP_SELF']?>?reqcode=<?php //echo $this->getArr['reqcode']?>&VIEW=MAIN&sortField=" + sortField + "&sortOrder" + sortField + "=" + sortOrder;
	document.standardView.action = uri;
	document.standardView.submit();
}

function frmAddHide () {
	//document.getElementById("txtType").style.visibility="hidden";
	document.getElementById("layerForm").style.visibility="hidden";
	//document.getElementById("layerFormLoc").style.visibility = "hidden";
	//document.getElementById("tblCompStruct").focus();
}

function frmEditHide () {
	//document.getElementById("txtType").style.visibility="hidden";
	document.getElementById("layerEditForm").style.visibility="hidden";
	//document.getElementById("layerFormLoc").style.visibility = "hidden";
}

function handle_request(val,uid,year,month,day,group,group_type){
	//val=document.getElementById("number_"+id).value;
	url="../../ajax_handle.php?action=argclass_member&year="+year+"&month="+month+"&group="+group+"&group_type="+group_type+"&uid="+uid+"&day="+day+"&val="+val;
	//alert(url);
	//sendRequest(url,"m_"+id+"|allnumber|allmoney");
	sendRequest(url);
}


<?php if(false) { ?>
function returnAdd() {

	location.href = "./CentralController.php?reqcode=<?php //echo $this->getArr['reqcode']?>&capturemode=addmode";

}

function returnDelete() {
	$check = 0;
	with (document.standardView) {
		for (var i=0; i < elements.length; i++) {
			if ((elements[i].type == 'checkbox') && (elements[i].checked == true)){
				$check = 1;
			}
		}
	}

	if ( $check == 1 ){
		document.standardView.delState.value = 'DeleteMode';
		document.standardView.pageNO.value=1;
		document.standardView.submit();
	}else{
		alert("<?php echo $lang_Error_SelectAtLeastOneRecordToDelete; ?>");
	}
}

<?php } else { ?>
function returnAdd() {
	var popup=window.open('../../templates/hrfunct/emppop.php?reqcode=<?php //echo $this->getArr['reqcode']?>','Employees','height=450,width=400,scrollbars=1');
	if(!popup.opener) popup.opener=self;
}
<?php } ?>

function returnSearch() {
	document.standardView.captureState.value = 'SearchMode';
	//document.standardView.pageNO.value=1;
	document.standardView.submit();
}

function batchAdd() {
	document.standardView.captureState.value = 'AddMode';
	//document.standardView.pageNO.value=1;
	document.standardView.action = '<?php echo $_SERVER['PHP_SELF']?>?salcode=salaryemp&action=Generate_BasicSalary_List';
	document.standardView.submit();
}

function doHandleAll()
{
	with (document.standardView) {
		if(elements['allCheck'].checked == false){
			doUnCheckAll();
		}
		else if(elements['allCheck'].checked == true){
			doCheckAll();
		}
	}
}

function doCheckAll() {
	with (document.standardView) {
		for (var i=0; i < elements.length; i++) {
			if (elements[i].type == 'checkbox') {
				elements[i].checked = true;
			}
		}
	}
}

function doUnCheckAll()
{
	with (document.standardView) {
		for (var i=0; i < elements.length; i++) {
			if (elements[i].type == 'checkbox') {
				elements[i].checked = false;
			}
		}
	}
}

/**
* If at least one day is unchecked, main check box would be unchecked
*/

function unCheckMain() {
	noOfCheckboxes = 0;
	noOfCheckedCheckboxes = 0;

	with (document.getElementById('standardView')) {
		for (i = 0; i < elements.length; i++) {
			if (elements[i].type == 'checkbox' && elements[i].name != 'allCheck') {
				noOfCheckboxes++;
				if (elements[i].checked == true) {
					noOfCheckedCheckboxes++;
				}

			}
		}
	}

	document.getElementById('allCheck').checked = (noOfCheckboxes == noOfCheckedCheckboxes);
}

function clear_form() {
	document.standardView.loc_code.options[0].selected=true;
	document.standardView.loc_name.value='';
}

function actionShowAdd() {
	$('addPanel').style.display = 'block';
	$('frmAddWorkShift').reset();
}

parent.scrollTo(0, 0);
//]]>
</script>
</head>
<body>

<div class="outerbox">
	<form name="standardView" id="standardView" method="post" action="<?php echo $_SERVER['PHP_SELF']?>?salcode=salaryemp">

		<div class="mainHeading"><h2>员工工资档案</h2></div>
		<input type="hidden" name="captureState" value="<?php //echo isset($this->postArr['captureState'])?$this->postArr['captureState']:''?>" />
		<input type="hidden" name="delState" value="" />
		<input type="hidden" name="pageNO" value="<?php echo $pageNO;?>" />
		<!--input type="hidden" name="pageNO" value="<?php //echo isset($this->postArr['pageNO'])?$this->postArr['pageNO']:'1'?>" /-->
		
		<?php include("../../templates/salary/Search.php");?>

		<?php
		if (isset($this->getArr['message'])) {
			$expString  = $this->getArr['message'];
			$messageType = CommonFunctions::getCssClassForMessage($expString);
			$messageType = 'failure';
		?>
		<div class="messagebar">
			<span class="<?php echo $messageType; ?>"><?php echo $$expString; ?></span>
		</div>
		<?php
		}
		?>

			<div class="actionbar">
				<div class="actionbuttons">
					<?php $locRights['add']=true;?>
					<input type="button" class="plainbtn"
					<?php echo ($locRights['add']) ? 'onclick="batchAdd();"' : 'style=visibility:hidden;'; ?>
						onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
						value="生成选中月份的员工工资档案" />

					<?php //if($this->getArr['reqcode']=='EMP') { ?>
					<?php if(true) { ?>
						<input type="button" class="plainbtn"
						<?php echo ($locRights['delete']) ? 'onclick="returnDelete();"' : 'style=visibility:hidden;'; ?>
							onmouseover="this.className='plainbtn plainbtnhov'" onmouseout="this.className='plainbtn'"
							value="<?php echo $lang_Common_Delete;?>" />

					<?php } ?>
				</div>
				<div class="noresultsbar"><?php echo (empty($emplist)) ? $norecorddisplay : '';?></div>
				<div class="pagingbar">
				<?php
				//$temp = $this->popArr['temp'];
				$currentPage = 1;
				$commonFunc = new CommonFunctions();
				$pageStr = $commonFunc->printPageLinks($records['Allcount'], $pageNO);
				$pageStr = preg_replace(array('/#first/', '/#previous/', '/#next/', '/#last/'), array($lang_empview_first, $lang_empview_previous, $lang_empview_next, $lang_empview_last), $pageStr);

				echo $pageStr;

				?>
				</div>
			<br class="clear" />
			</div>
			<br class="clear" />
				<table cellspacing="0" cellpadding="0" class="data-table">
					<thead>
					<tr>
						<td scope="col" width="20px;">姓名</td>
						<td scope="col" width="15px;">月份</td>
						<td scope="col" width="20px;">职位</td>
						<td scope="col" width="20px;">职位薪水</td>
						<td scope="col" width="45px;">等级津贴</td>
						<td scope="col" width="50px;">技能津贴</td>
						<td scope="col" width="20px;">高温津贴</td>
						<td scope="col" width="20px;">夜班津贴</td>
						<td scope="col" width="45px;">其他津贴</td>
						<td scope="col" width="20px;">养老保险</td>
						<td scope="col" width="20px;">医疗保险</td>
						<td scope="col" width="20px;">失业保险</td>
						<td scope="col" width="20px;">生育保险</td>
						<td scope="col" width="20px;">住房公积金</td>
					</tr>
					</thead>

					<tbody>
					<?php
					$n = count($list);
					$j=0;
					foreach($list as $sid=>$salinfo) {
						$j++;
						$rstyle = $j%2==0 ? " class='row1'" : "";
						//$inptyle = $j%2==0 ? " style='text-align:center;background-color:#ffb;'" : " style='text-align:center;'";
						echo "<tr ".$rstyle."><td>".$salinfo['emp_name']."</td><td>".$salinfo['year']."-".$salinfo['month']."</td><td>".$salinfo['jobtit_name']."</td>";
						if($salinfo['tec_allowance']) {
							//$tec_allowances = unserialize($salinfo['tec_allowance']);
							//$remarks = unserialize($salinfo['tec_allowance_remark']);
							//print_r($tec_allowances);print_r($remarks);exit;
							//if(!is_array($tec_allowances)) $tec_allowances = array();
							//if(!is_array($remarks)) $remarks = array();
							$tecStr = $salinfo['tec_allowance'].'('.$salinfo['tec_allowance_remark'].')';
							/*foreach ($tec_allowances as $i=>$tec_allowance) {
								$tecStr .= $tec_allowance."(".$remarks[$i].")<br/>";
							}*/
						}else {
							$tecStr = 0;
						}
						if ($salinfo['adm_exam_salary']) {
							$examStr = $salinfo['adm_exam_salary'].'('.$salinfo['adm_exam_remarks'].')';
						}else {
							$examStr = 0;
						}
						echo "<td>".$salinfo['jobtit_salary']."</td><td>".$examStr."</td><td>".$tecStr."</td>";
						echo "<td>".$salinfo['hight_temp_allowance']."</td><td>".$salinfo['night_work_allowance']."</td>";
						if($salinfo['other_allowance_remark']) {
							echo "<td>".$salinfo['other_allowance']."(".$salinfo['other_allowance_remark'].")</td>";
						}else {
							echo "<td>".$salinfo['other_allowance']."</td>";
						}
						echo "<td>".$salinfo['endowment_insurance']."</td>";
						echo "<td>".$salinfo['medical_insurance']."</td>";
						echo "<td>".$salinfo['losework_insurance']."</td>";
						echo "<td>".$salinfo['maternity_insurance']."</td>";
						echo "<td>".$salinfo['housing_fund']."</td>";
						echo "</tr>";
					}
					?>

					</tbody>
				</table>
	</form>
</div>
   
<script type="text/javascript">
<!--
if (document.getElementById && document.createElement) {
	roundBorder('outerbox');
}
-->
</script>
</body>
</html>
